package thread;

/**
 * Created with IntelliJ IDEA
 * Description：
 * User：chenshu
 * Date：2023-11-01
 * Time：12:30
 */
class MyThread extends Thread{
    @Override
    public void run() {
        while (true) {
            System.out.println("hello thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class Demo1 {
    public static void main(String[] args) {
        Thread t = new MyThread();
        //t.start();//两个线程并发执行
        t.run();//没有创建新的线程，只是在main线程中调用run里的内容

        while (true) {
            System.out.println("hello world!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
